package cn.codeforfun.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.List;

/**
 * Created by Administrator on 2017/2/15 0015.
 */
@Repository
public class UserDaoImpl implements UserDaoCustom {
    @Autowired
    private EntityManager entityManager;

    @Override
    public List<User> bizUsernameAndPassword(String username, String password) {
        Query query = entityManager.createQuery("select u from User u where u.username=:username and u.password=:password")
                .setParameter("username", username).setParameter("password", password);
        List resultList = query.getResultList();
        return resultList;
    }
}
